package com.houtai.service.resume;

import com.aliyun.openservices.oss.model.ObjectMetadata;
import com.houtai.base.ResultVo;
import com.houtai.bean.*;
import com.houtai.bean.dto.resume.TdResumeInsertDto;
import com.houtai.bean.vo.file.FileVo;
import com.houtai.bean.vo.resume.TdResumeDetail;
import com.houtai.bean.vo.resume.TdResumeDetailVo;
import com.houtai.common.Contant;
import com.houtai.common.oss.OssUtil;
import com.houtai.dao.TdJobExperienceDao;
import com.houtai.dao.TdProjectExperienceDao;
import com.houtai.dao.TdResumeDao;
import com.houtai.dao.TsJzDictDao;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

@Service
public class ResumeService {
    private static Logger logger = Logger.getLogger(ResumeService.class);
    @Autowired
    private TdResumeDao tdResumeDao;

    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private TdProjectExperienceDao tdProjectExperienceDao;
    @Autowired
    private TdJobExperienceDao tdJobExperienceDao;
    @Autowired
    private TsJzDictDao tsJzDictDao;
    /**
     * @Purpose:    上传附件简历
     * @param:      dto
     * @Version:    1.0
     * @Author:     li
     * @time:       2019/8/21
     * @return:     TdResumeDetailVo
     */
    public FileVo updateTdResumeAttachmentUrl(String token, MultipartFile frontFile) {
        String logInfo = this.getClass().getName() + ":updateTdResumeAttachmentUrl:";
        FileVo vo = new FileVo();
        logger.info("======" + logInfo + "begin======");
        try {
            User user = (User)redisTemplate.opsForValue().get(token);
            TdResumeDetail tdResumeDetail = tdResumeDao.findTdResume(user.getUser_id());
            if (tdResumeDetail != null) {
                SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddhhmmssS", Locale.CHINA);
                String frontFileName = frontFile.getOriginalFilename().substring(frontFile.getOriginalFilename().lastIndexOf(".") + 1);
                String imgName = formatter.format(new Date(System.currentTimeMillis()));
                String frontSavePath = Contant.FILE_IMG+"/" + "resume/" + user.getUser_id() + "/" + imgName + "." + frontFileName;
                ObjectMetadata frontMetadata = new ObjectMetadata();
                InputStream inputStream = frontFile.getInputStream();
                frontMetadata.setContentLength(inputStream.available());
                OssUtil.uploadInputStream(inputStream, frontMetadata, frontSavePath);
                tdResumeDetail.setAttachment_url(Contant.DOMAIN +  Contant.FILE_IMG+"/"+"resume"+"/"  + user.getUser_id() + "/"+imgName + "." + frontFileName);
                tdResumeDao.updateTdResumeAttachmentUrl(tdResumeDetail);
                vo.setMark("0");
                vo.setTip("查询成功");
                vo.setFile_name(imgName + "." + frontFileName);
                vo.setFile_url(Contant.DOMAIN +  Contant.FILE_IMG+"/"+"resume"+"/" + user.getUser_id() + "/" + imgName + "." + frontFileName);
            } else {
                vo.setMark("1");
                vo.setTip("请先填写简历");
            }

        } catch (Exception e) {
            logger.error("======error:" + e.toString() + "======");
            vo.setMark("-1");
            vo.setTip("系统错误");
        }
        logger.info("======" + logInfo + "end======");
        return vo;
    }
    /**
     * @Purpose:    简历数据详情
     * @param:      dto
     * @Version:    1.0
     * @Author:     li
     * @time:       2019/8/21
     * @return:     TdResumeDetailVo
     */
    public TdResumeDetailVo resumeDetail(String token) {
        String logInfo = this.getClass().getName() + ":resumeDetail:";
        TdResumeDetailVo vo = new TdResumeDetailVo();
        logger.info("======" + logInfo + "begin======");
        try {
            User user = (User)redisTemplate.opsForValue().get(token);
            TdResumeDetail tdResumeDetail = tdResumeDao.findTdResume(user.getUser_id());
            if (tdResumeDetail != null) {
                vo.setJobs(tdJobExperienceDao.findTdJobExperienceList(tdResumeDetail.getResume_id()));
                vo.setProjects(tdProjectExperienceDao.findTdProjectExperienceList(tdResumeDetail.getResume_id()));
                vo.setDetail(tdResumeDetail);
                vo.setMark("0");
                vo.setTip("查询成功");
            } else {
                vo.setMark("1");
                vo.setTip("未填写简历");
            }

        } catch (Exception e) {
            logger.error("======error:" + e.toString() + "======");
            vo.setMark("-1");
            vo.setTip("系统错误");
        }
        logger.info("======" + logInfo + "end======");
        return vo;
    }
    /**
     * @Purpose:    添加简历
     * @param:      dto
     * @Version:    1.0
     * @Author:     li
     * @time:       2019/8/21
     * @return:     ResultVo
     */
    @Transactional
    public synchronized ResultVo insertResume(TdResumeInsertDto dto, String token) {
        String logInfo = this.getClass().getName() + ":insertResume:";
        ResultVo vo = new ResultVo();
        logger.info("======" + logInfo + "begin======");
        try {
            User user = (User)redisTemplate.opsForValue().get(token);
            if (tdResumeDao.findTdResume(user.getUser_id()) != null) {
                vo.setMark("1");
                vo.setTip("简历已存在不可添加");
            } else {
                TsJzDict province = tsJzDictDao.findDictById(dto.getProvince_id());
                if (province != null && province.getCode_type().equals("province")) {
                    TsJzDict city = tsJzDictDao.findDictById(dto.getCity_id());
                    if (city != null && city.getParent_id() == province.getDict_id()) {
                        TsJzDict job_status = tsJzDictDao.findDictById(dto.getJob_status_id());
                        if (job_status != null && job_status.getCode_type().equals("job_status")) {
                            TsJzDict diploma = tsJzDictDao.findDictById(dto.getDiploma_id());
                            if (diploma != null && diploma.getCode_type().equals("diploma")) {
                                TsJzDict jobs = tsJzDictDao.findDictById(dto.getJobs_id());
                                if (jobs != null && jobs.getCode_type().equals("jobs")) {
                                    TsJzDict wage = tsJzDictDao.findDictById(dto.getWage_id());
                                    if (wage != null && wage.getCode_type().equals("wage")) {
                                        if (dto.getProject_experience().size() > 0) {
                                            if (dto.getJob_experience().size() > 0) {

                                                TdResume tdResume = new TdResume();
                                                tdResume.setAge(dto.getAge());
                                                tdResume.setBirthday(dto.getBirthday());
                                                tdResume.setCity_id(dto.getCity_id());
                                                tdResume.setDiploma(diploma.getCode_name());
                                                tdResume.setDiploma_id(dto.getDiploma_id());
                                                tdResume.setGraduate_school(dto.getGraduate_school());
                                                tdResume.setHead_img(dto.getHead_img());
                                                tdResume.setJob_status(job_status.getCode_name());
                                                tdResume.setJob_status_id(dto.getJob_status_id());
                                                tdResume.setJobs(jobs.getCode_name());
                                                tdResume.setJobs_id(dto.getJobs_id());
                                                tdResume.setPhone_no(dto.getPhone_no());
                                                tdResume.setProvince_city(province.getCode_name() + city.getCode_name());
                                                tdResume.setProvince_id(dto.getProvince_id());
                                                tdResume.setSex(dto.getSex());
                                                tdResume.setUser_id(user.getUser_id());
                                                tdResume.setUser_name(dto.getUser_name());
                                                tdResume.setWage(wage.getCode_name());
                                                tdResume.setWage_id(dto.getWage_id());
                                                tdResume.setWork_ages(dto.getWork_ages());
                                                tdResumeDao.insertTdResume(tdResume);
                                                for (int i = 0; i < dto.getProject_experience().size(); i ++) {
                                                    TsJzDict project_roles = tsJzDictDao.findDictById(dto.getProject_experience().get(i).getProject_roles_id());
                                                    if (project_roles != null && project_roles.getCode_type().equals("project_roles")) {
                                                        TdProjectExperience projectExperience = new TdProjectExperience();
                                                        projectExperience.setEnd_time(dto.getProject_experience().get(i).getEnd_time());
                                                        projectExperience.setProject_content(dto.getProject_experience().get(i).getProject_content());
                                                        projectExperience.setProject_experience_id(dto.getProject_experience().get(i).getProject_roles_id());
                                                        projectExperience.setProject_name(dto.getProject_experience().get(i).getProject_name());
                                                        projectExperience.setProject_roles(project_roles.getCode_name());
                                                        projectExperience.setProject_roles_id(dto.getProject_experience().get(i).getProject_roles_id());
                                                        projectExperience.setProject_url(dto.getProject_experience().get(i).getProject_url());
                                                        projectExperience.setResume_id(tdResume.getResume_id());
                                                        projectExperience.setStart_time(dto.getProject_experience().get(i).getStart_time());
                                                        projectExperience.setState(0);
                                                        projectExperience.setUser_id(user.getUser_id());
                                                        tdProjectExperienceDao.insertTdProjectExperience(projectExperience);
                                                    } else {
                                                        vo.setMark("1");
                                                        vo.setTip("项目角色不存在");
                                                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                                        return vo;
                                                    }
                                                }
                                                for (int i = 0; i < dto.getJob_experience().size(); i ++) {
                                                    TsJzDict department = tsJzDictDao.findDictById(dto.getJob_experience().get(i).getDepartment_id());
                                                    if (department != null && department.getCode_type().equals("department")) {
                                                        TsJzDict industry = tsJzDictDao.findDictById(dto.getJob_experience().get(i).getIndustry_id());
                                                        if (industry != null && industry.getCode_type().equals("industry")) {
                                                            TsJzDict jobs1 = tsJzDictDao.findDictById(dto.getJob_experience().get(i).getJobs_id());
                                                            if (jobs1 != null && jobs1.getCode_type().equals("jobs")) {
                                                                TsJzDict profession = tsJzDictDao.findDictById(dto.getJob_experience().get(i).getProfession_id());
                                                                if (profession != null && profession.getCode_type().equals("profession")) {
                                                                    String[] split = dto.getJob_experience().get(i).getSkills_label_id().split(",");
                                                                    if (split.length < 4) {
                                                                        String skills_label = "";
                                                                        for (int j = 0; j < split.length; j ++) {
                                                                            TsJzDict label = tsJzDictDao.findDictById(Integer.valueOf(split[j]));
                                                                            if (label != null && label.getCode_type().equals("skills_label")) {
                                                                                if (j != 0) {
                                                                                    skills_label += label.getCode_name();
                                                                                } else {
                                                                                    skills_label +=   "," + label.getCode_name();
                                                                                }

                                                                            } else {
                                                                                vo.setMark("1");
                                                                                vo.setTip("有技能标签不存在");
                                                                                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                                                                return vo;
                                                                            }
                                                                        }
                                                                        TdJobExperience tdJobExperience = new TdJobExperience();
                                                                        tdJobExperience.setCompany_name(dto.getJob_experience().get(i).getCompany_name());
                                                                        tdJobExperience.setDepartment(department.getCode_name());
                                                                        tdJobExperience.setDepartment_id(dto.getJob_experience().get(i).getDepartment_id());
                                                                        tdJobExperience.setEnd_time(dto.getJob_experience().get(i).getEnd_time());
                                                                        tdJobExperience.setIndustry(industry.getCode_name());
                                                                        tdJobExperience.setIndustry_id(dto.getJob_experience().get(i).getIndustry_id());
                                                                        tdJobExperience.setJob_content(dto.getJob_experience().get(i).getJob_content());
                                                                        tdJobExperience.setJobs(jobs1.getCode_name());
                                                                        tdJobExperience.setJobs_id(dto.getJob_experience().get(i).getJobs_id());
                                                                        tdJobExperience.setProfession(profession.getCode_name());
                                                                        tdJobExperience.setProfession_id(dto.getJob_experience().get(i).getProfession_id());
                                                                        tdJobExperience.setResume_id(tdResume.getResume_id());
                                                                        tdJobExperience.setSkills_label(skills_label);
                                                                        tdJobExperience.setSkills_label_id(dto.getJob_experience().get(i).getSkills_label_id());
                                                                        tdJobExperience.setStart_time(dto.getJob_experience().get(i).getStart_time());
                                                                        tdJobExperience.setState(0);
                                                                        tdJobExperience.setUser_id(user.getUser_id());
                                                                        tdJobExperienceDao.insertTdJobExperience(tdJobExperience);
                                                                    } else {
                                                                        vo.setMark("1");
                                                                        vo.setTip("技能标签最多3个");
                                                                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                                                        return vo;
                                                                    }

                                                                } else {
                                                                    vo.setMark("1");
                                                                    vo.setTip("职位类型不存在");
                                                                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                                                    return vo;
                                                                }

                                                            } else {
                                                                vo.setMark("1");
                                                                vo.setTip("职位名称不存在");
                                                                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                                                return vo;
                                                            }


                                                        } else {
                                                            vo.setMark("1");
                                                            vo.setTip("所属行业不存在");
                                                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                                            return vo;
                                                        }

                                                    } else {
                                                        vo.setMark("1");
                                                        vo.setTip("所属部门不存在");
                                                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                                        return vo;
                                                    }
                                                }
                                                vo.setMark("0");
                                                vo.setTip("成功");
                                            } else {
                                                vo.setMark("1");
                                                vo.setTip("工作经历最少一个");
                                            }
                                        } else {
                                            vo.setMark("1");
                                            vo.setTip("项目经历最少一个");
                                        }


                                    } else {
                                        vo.setMark("1");
                                        vo.setTip("工资区间不存在");
                                    }
                                } else {
                                    vo.setMark("1");
                                    vo.setTip("期望职位不存在");
                                }
                            } else {
                                vo.setMark("1");
                                vo.setTip("学历不存在");
                            }
                        } else {
                            vo.setMark("1");
                            vo.setTip("求职状态不存在");
                        }

                    } else {
                        vo.setMark("1");
                        vo.setTip("市不存在");
                    }
                } else {
                    vo.setMark("1");
                    vo.setTip("省不存在");
                }

            }


        } catch (Exception e) {
            logger.error("======error:" + e.toString() + "======");
            vo.setMark("-1");
            vo.setTip("系统错误");
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
        logger.info("======" + logInfo + "end======");
        return vo;
    }

    /**
     * @Purpose:    修改简历
     * @param:      dto
     * @Version:    1.0
     * @Author:     li
     * @time:       2019/8/21
     * @return:     ResultVo
     */
    @Transactional
    public synchronized ResultVo updateResume(TdResumeInsertDto dto, String token) {
        String logInfo = this.getClass().getName() + ":updateResume:";
        ResultVo vo = new ResultVo();
        logger.info("======" + logInfo + "begin======");
        try {
            User user = (User)redisTemplate.opsForValue().get(token);
            TdResumeDetail tdResume = tdResumeDao.findTdResume(user.getUser_id());
            if (tdResume == null) {
                vo.setMark("1");
                vo.setTip("简历不存在，请先添加");
            } else {
                TsJzDict province = tsJzDictDao.findDictById(dto.getProvince_id());
                if (province != null && province.getCode_type().equals("province")) {
                    TsJzDict city = tsJzDictDao.findDictById(dto.getCity_id());
                    if (city != null && city.getParent_id() == province.getDict_id()) {
                        TsJzDict job_status = tsJzDictDao.findDictById(dto.getJob_status_id());
                        if (job_status != null && job_status.getCode_type().equals("job_status")) {
                            TsJzDict diploma = tsJzDictDao.findDictById(dto.getDiploma_id());
                            if (diploma != null && diploma.getCode_type().equals("diploma")) {
                                TsJzDict jobs = tsJzDictDao.findDictById(dto.getJobs_id());
                                if (jobs != null && jobs.getCode_type().equals("jobs")) {
                                    TsJzDict wage = tsJzDictDao.findDictById(dto.getWage_id());
                                    if (wage != null && wage.getCode_type().equals("wage")) {
                                        if (dto.getProject_experience().size() > 0) {
                                            if (dto.getJob_experience().size() > 0) {


                                                tdResume.setAge(dto.getAge());
                                                tdResume.setBirthday(dto.getBirthday());
                                                tdResume.setCity_id(dto.getCity_id());
                                                tdResume.setDiploma(diploma.getCode_name());
                                                tdResume.setDiploma_id(dto.getDiploma_id());
                                                tdResume.setGraduate_school(dto.getGraduate_school());
                                                tdResume.setHead_img(dto.getHead_img());
                                                tdResume.setJob_status(job_status.getCode_name());
                                                tdResume.setJob_status_id(dto.getJob_status_id());
                                                tdResume.setJobs(jobs.getCode_name());
                                                tdResume.setJobs_id(dto.getJobs_id());
                                                tdResume.setPhone_no(dto.getPhone_no());
                                                tdResume.setProvince_city(province.getCode_name() + city.getCode_name());
                                                tdResume.setProvince_id(dto.getProvince_id());
                                                tdResume.setSex(dto.getSex());
                                                tdResume.setUser_name(dto.getUser_name());
                                                tdResume.setWage(wage.getCode_name());
                                                tdResume.setWage_id(dto.getWage_id());
                                                tdResume.setWork_ages(dto.getWork_ages());
                                                tdResumeDao.updateTdResumeDetail(tdResume);

                                                tdProjectExperienceDao.updateTdProjectExperienceState(user.getUser_id());
                                                for (int i = 0; i < dto.getProject_experience().size(); i ++) {
                                                    TsJzDict project_roles = tsJzDictDao.findDictById(dto.getProject_experience().get(i).getProject_roles_id());
                                                    if (project_roles != null && project_roles.getCode_type().equals("project_roles")) {
                                                        TdProjectExperience projectExperience = tdProjectExperienceDao.findTdProjectExperience(user.getUser_id(), dto.getProject_experience().get(i).getProject_roles_id());
                                                        if (projectExperience != null) {
                                                            projectExperience.setEnd_time(dto.getProject_experience().get(i).getEnd_time());
                                                            projectExperience.setProject_content(dto.getProject_experience().get(i).getProject_content());
                                                            projectExperience.setProject_experience_id(dto.getProject_experience().get(i).getProject_roles_id());
                                                            projectExperience.setProject_name(dto.getProject_experience().get(i).getProject_name());
                                                            projectExperience.setProject_roles(project_roles.getCode_name());
                                                            projectExperience.setProject_roles_id(dto.getProject_experience().get(i).getProject_roles_id());
                                                            projectExperience.setProject_url(dto.getProject_experience().get(i).getProject_url());
                                                            projectExperience.setStart_time(dto.getProject_experience().get(i).getStart_time());
                                                            projectExperience.setState(0);
                                                            projectExperience.setUser_id(user.getUser_id());
                                                            tdProjectExperienceDao.updateTdProjectExperience(projectExperience);
                                                        } else {
                                                            projectExperience = new TdProjectExperience();
                                                            projectExperience.setEnd_time(dto.getProject_experience().get(i).getEnd_time());
                                                            projectExperience.setProject_content(dto.getProject_experience().get(i).getProject_content());
                                                            projectExperience.setProject_experience_id(dto.getProject_experience().get(i).getProject_roles_id());
                                                            projectExperience.setProject_name(dto.getProject_experience().get(i).getProject_name());
                                                            projectExperience.setProject_roles(project_roles.getCode_name());
                                                            projectExperience.setProject_roles_id(dto.getProject_experience().get(i).getProject_roles_id());
                                                            projectExperience.setProject_url(dto.getProject_experience().get(i).getProject_url());
                                                            projectExperience.setResume_id(tdResume.getResume_id());
                                                            projectExperience.setStart_time(dto.getProject_experience().get(i).getStart_time());
                                                            projectExperience.setState(0);
                                                            projectExperience.setUser_id(user.getUser_id());
                                                            tdProjectExperienceDao.insertTdProjectExperience(projectExperience);
                                                        }

                                                    } else {
                                                        vo.setMark("1");
                                                        vo.setTip("项目角色不存在");
                                                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                                        return vo;
                                                    }
                                                }
                                                tdJobExperienceDao.updateTdJobExperienceState(user.getUser_id());
                                                for (int i = 0; i < dto.getJob_experience().size(); i ++) {
                                                    TsJzDict department = tsJzDictDao.findDictById(dto.getJob_experience().get(i).getDepartment_id());
                                                    if (department != null && department.getCode_type().equals("department")) {
                                                        TsJzDict industry = tsJzDictDao.findDictById(dto.getJob_experience().get(i).getIndustry_id());
                                                        if (industry != null && industry.getCode_type().equals("industry")) {
                                                            TsJzDict jobs1 = tsJzDictDao.findDictById(dto.getJob_experience().get(i).getJobs_id());
                                                            if (jobs1 != null && jobs1.getCode_type().equals("jobs")) {
                                                                TsJzDict profession = tsJzDictDao.findDictById(dto.getJob_experience().get(i).getProfession_id());
                                                                if (profession != null && profession.getCode_type().equals("profession")) {
                                                                    String[] split = dto.getJob_experience().get(i).getSkills_label_id().split(",");
                                                                    if (split.length < 4) {
                                                                        String skills_label = "";
                                                                        for (int j = 0; j < split.length; j ++) {
                                                                            TsJzDict label = tsJzDictDao.findDictById(Integer.valueOf(split[j]));
                                                                            if (label != null && label.getCode_type().equals("skills_label")) {
                                                                                if (j != 0) {
                                                                                    skills_label += label.getCode_name();
                                                                                } else {
                                                                                    skills_label +=   "," + label.getCode_name();
                                                                                }

                                                                            } else {
                                                                                vo.setMark("1");
                                                                                vo.setTip("有技能标签不存在");
                                                                                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                                                                return vo;
                                                                            }
                                                                        }
                                                                        TdJobExperience tdJobExperience = tdJobExperienceDao.findTdJobExperience(user.getUser_id(), dto.getJob_experience().get(i).getJob_experience_id());
                                                                        if (tdJobExperience != null) {
                                                                            tdJobExperience.setCompany_name(dto.getJob_experience().get(i).getCompany_name());
                                                                            tdJobExperience.setDepartment(department.getCode_name());
                                                                            tdJobExperience.setDepartment_id(dto.getJob_experience().get(i).getDepartment_id());
                                                                            tdJobExperience.setEnd_time(dto.getJob_experience().get(i).getEnd_time());
                                                                            tdJobExperience.setIndustry(industry.getCode_name());
                                                                            tdJobExperience.setIndustry_id(dto.getJob_experience().get(i).getIndustry_id());
                                                                            tdJobExperience.setJob_content(dto.getJob_experience().get(i).getJob_content());
                                                                            tdJobExperience.setJobs(jobs1.getCode_name());
                                                                            tdJobExperience.setJobs_id(dto.getJob_experience().get(i).getJobs_id());
                                                                            tdJobExperience.setProfession(profession.getCode_name());
                                                                            tdJobExperience.setProfession_id(dto.getJob_experience().get(i).getProfession_id());
                                                                            tdJobExperience.setSkills_label(skills_label);
                                                                            tdJobExperience.setSkills_label_id(dto.getJob_experience().get(i).getSkills_label_id());
                                                                            tdJobExperience.setStart_time(dto.getJob_experience().get(i).getStart_time());
                                                                            tdJobExperience.setState(0);

                                                                            tdJobExperienceDao.updateTdJobExperience(tdJobExperience);
                                                                        } else {
                                                                            tdJobExperience = new TdJobExperience();
                                                                            tdJobExperience.setCompany_name(dto.getJob_experience().get(i).getCompany_name());
                                                                            tdJobExperience.setDepartment(department.getCode_name());
                                                                            tdJobExperience.setDepartment_id(dto.getJob_experience().get(i).getDepartment_id());
                                                                            tdJobExperience.setEnd_time(dto.getJob_experience().get(i).getEnd_time());
                                                                            tdJobExperience.setIndustry(industry.getCode_name());
                                                                            tdJobExperience.setIndustry_id(dto.getJob_experience().get(i).getIndustry_id());
                                                                            tdJobExperience.setJob_content(dto.getJob_experience().get(i).getJob_content());
                                                                            tdJobExperience.setJobs(jobs1.getCode_name());
                                                                            tdJobExperience.setJobs_id(dto.getJob_experience().get(i).getJobs_id());
                                                                            tdJobExperience.setProfession(profession.getCode_name());
                                                                            tdJobExperience.setProfession_id(dto.getJob_experience().get(i).getProfession_id());
                                                                            tdJobExperience.setResume_id(tdResume.getResume_id());
                                                                            tdJobExperience.setSkills_label(skills_label);
                                                                            tdJobExperience.setSkills_label_id(dto.getJob_experience().get(i).getSkills_label_id());
                                                                            tdJobExperience.setStart_time(dto.getJob_experience().get(i).getStart_time());
                                                                            tdJobExperience.setState(0);
                                                                            tdJobExperience.setUser_id(user.getUser_id());
                                                                            tdJobExperienceDao.insertTdJobExperience(tdJobExperience);
                                                                        }

                                                                    } else {
                                                                        vo.setMark("1");
                                                                        vo.setTip("技能标签最多3个");
                                                                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                                                        return vo;
                                                                    }

                                                                } else {
                                                                    vo.setMark("1");
                                                                    vo.setTip("职位类型不存在");
                                                                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                                                    return vo;
                                                                }

                                                            } else {
                                                                vo.setMark("1");
                                                                vo.setTip("职位名称不存在");
                                                                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                                                return vo;
                                                            }


                                                        } else {
                                                            vo.setMark("1");
                                                            vo.setTip("所属行业不存在");
                                                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                                            return vo;
                                                        }

                                                    } else {
                                                        vo.setMark("1");
                                                        vo.setTip("所属部门不存在");
                                                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                                        return vo;
                                                    }
                                                }
                                                vo.setMark("0");
                                                vo.setTip("成功");
                                            } else {
                                                vo.setMark("1");
                                                vo.setTip("工作经历最少一个");
                                            }
                                        } else {
                                            vo.setMark("1");
                                            vo.setTip("项目经历最少一个");
                                        }


                                    } else {
                                        vo.setMark("1");
                                        vo.setTip("工资区间不存在");
                                    }
                                } else {
                                    vo.setMark("1");
                                    vo.setTip("期望职位不存在");
                                }
                            } else {
                                vo.setMark("1");
                                vo.setTip("学历不存在");
                            }
                        } else {
                            vo.setMark("1");
                            vo.setTip("求职状态不存在");
                        }

                    } else {
                        vo.setMark("1");
                        vo.setTip("市不存在");
                    }
                } else {
                    vo.setMark("1");
                    vo.setTip("省不存在");
                }

            }


        } catch (Exception e) {
            logger.error("======error:" + e.toString() + "======");
            vo.setMark("-1");
            vo.setTip("系统错误");
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
        logger.info("======" + logInfo + "end======");
        return vo;
    }
}
